/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.hibernate.model;


import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.javacommon.base.BaseEntity;
import org.hibernate.validator.constraints.Length;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "AD_COLUMN")
public class AdColumn extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "广告主栏目表";
	public static final String ALIAS_ID = "栏目id";
	public static final String ALIAS_AD_OWNER_ID = "广告主id";
	public static final String ALIAS_URL = "栏目url";
	public static final String ALIAS_USER_ID = "用户id";
	public static final String ALIAS_NAME = "栏目名称";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
	
	private Long id;
	
	private Long adOwnerId;
	@Length(max=1000)
	private String url;
	
	private Long userId;
	@Length(max=500)
	private java.lang.String name;
	//columns END


	public AdColumn(){
	}

	public AdColumn(
		Long id
	){
		this.id = id;
	}

	

	public void setId(Long value) {
		this.id = value;
	}
	
	@Id
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native") 
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 10)
	public Long getId() {
		return this.id;
	}
	
	@Column(name = "AD_OWNER_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public Long getAdOwnerId() {
		return this.adOwnerId;
	}
	
	public void setAdOwnerId(Long value) {
		this.adOwnerId = value;
	}
	
	@Column(name = "URL", unique = false, nullable = true, insertable = true, updatable = true, length = 1000)
	public String getUrl() {
		return this.url;
	}
	
	public void setUrl(String value) {
		this.url = value;
	}
	
	@Column(name = "USER_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public Long getUserId() {
		return this.userId;
	}
	
	public void setUserId(Long value) {
		this.userId = value;
	}
	
	@Column(name = "NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 500)
	public java.lang.String getName() {
		return this.name;
	}
	
	public void setName(java.lang.String value) {
		this.name = value;
	}
	

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("AdOwnerId",getAdOwnerId())
			.append("Url",getUrl())
			.append("UserId",getUserId())
			.append("Name",getName())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof AdColumn == false) return false;
		if(this == obj) return true;
		AdColumn other = (AdColumn)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return "广告主栏目";
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return getId();
	}
	
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return getName();
	}
}

